<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('修改FTP信息')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-post-edit" th:object="${ftp}">
			<input id="Id" name="Id" type="hidden" th:field="*{id}"/>
			<input name="treeId" type="hidden" id="treeId"/>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">配置名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="configName" id="configName" th:field="*{configName}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">FTP服务器IP：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="serverIp" id="serverIp" th:field="*{serverIp}" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">FTP端口：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="serverPort" id="serverPort" th:field="*{serverPort}" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">FTP账号：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="ftpName" id="ftpName" th:field="*{ftpName}" >
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">FTP密码：</label>
				<div class="col-sm-8">
					<div class="input-group">
						<input id="ftpPassword" name="ftpPassword" class="form-control" type="password" th:value="${ftp.ftpPassword}" >
						<span class="input-group-addon" title="FTP密码,鼠标按下显示密码"
							  onmousedown="$('#ftpPassword').attr('type','text')"
							  onmouseup="$('#ftpPassword').attr('type','password')"><i class="fa fa-key"></i></span>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">ftp文件目录：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="ftpDir" id="ftpDir" th:field="*{ftpDir}" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">是否使用文件结构目录：</label>
				<div class="col-sm-8">
					<label class="radio-box"> <input type="radio" name="muluyn" th:field="*{muluyn}" value="0"/> 使用 </label>
					<label class="radio-box"> <input type="radio" name="muluyn" th:field="*{muluyn}" value="1"/> 不使用</label>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">云平台用户名：</label>
				<div class="col-sm-8">
					<div class="input-group">
						<input name="treeName" onclick="selectFTPTree()" id="treeName" type="text" th:field="*{userName}" class="form-control" required>
						<span class="input-group-addon"><i class="fa fa-search"></i></span>
					</div>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "system/post";
		
		/*$("#form-post-edit").validate({
			onkeyup: false,
			rules:{
				postName:{
					remote: {
		                url: ctx + "system/post/checkPostNameUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"postId": function() {
							    return $("input[name='postId']").val();
							},
		                	"postName" : function() {
		                        return $.common.trim($("#postName").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
				postCode:{
					remote: {
		                url: ctx + "system/post/checkPostCodeUnique",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"postId": function() {
							    return $("input[name='postId']").val();
							},
		                	"postCode" : function() {
		                		return $.common.trim($("#postCode").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
				postSort:{
					digits:true
				},
			},
			messages: {
		        "postCode": {
		            remote: "岗位编码已经存在"
		        },
		        "postName": {
		            remote: "岗位名称已经存在"
		        }
		    },
		    focusCleanup: true
		});*/
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/edit", $('#form-post-edit').serialize());
	        }
	    }

        /**
         * FTP管理-新增-选择用户列表
         */
        function selectFTPTree() {
            var url = ctx + "system/post/selectUserTree/";
            var options = {
                title: '选择用户',
                width: "380",
                url: url,
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            $.modal.close(index);
        }
	</script>
</body>
</html>
